NexusPi Git Node
Provisioning.h HEAD (592c826d) Text, 4.29 KB
T8b949e// Copyright (C) 2026, Chad Attermann
T8b949e// This program is free software: you can redistribute it and/or modify
T8b949e// it under the terms of the GNU General Public License as published by
T8b949e// the Free Software Foundation, either version 3 of the License, or
T8b949e// (at your option) any later version.
T8b949e// This program is distributed in the hope that it will be useful,
T8b949e// but WITHOUT ANY WARRANTY; without even the implied warranty of
T8b949e// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
T8b949e// GNU General Public License for more details.
Tff7b72#Tff7b72pragma once
Tff7b72#Tff7b72ifdef HAS_PROVISIONING
Tff7b72#Tff7b72include T8b949e<microReticulum/Bytes.h>
Tff7b72#Tff7b72include T8b949e<stddef.h>
Tff7b72#Tff7b72include T8b949e<stdint.h>
T8b949e// Per-platform cap on a single inbound CMD_PROVISION_REQ payload. Sized
T8b949e// to admit the largest plausible host request (SetState across all radio
T8b949e// + general fields) without giving up too much RAM on tight nRF52 builds.
Tff7b72#Tff7b72if MCU_VARIANT == MCU_NRF52
Tff7b72#Tff7b72define PROVISION_RX_BUF_MAX 512
Tff7b72#Tff7b72else
Tff7b72#Tff7b72define PROVISION_RX_BUF_MAX 2048
Tff7b72#Tff7b72endif
T8b949e// ---------------------------------------------------------------------------
T8b949e// Provisioning namespace + field IDs.
T8b949e//
T8b949e// Namespace IDs 1-2 are RNS built-ins (Reticulum, Transport); 100-199
T8b949e// are the official app range. PROV_NS_RADIO and its field IDs are kept
T8b949e// here as a reference for the (currently disabled) radio namespace —
T8b949e// EEPROM (driven by rnodeconf) remains the source of truth for radio
T8b949e// configuration. See register_provisioning_namespaces() below.
T8b949e//
T8b949e// NOTE: **NEVER** change these values once they are in production. Only additions can be made.
T8b949e// ---------------------------------------------------------------------------
Tff7b72#Tff7b72define PROV_NS_GENERAL 100
Tff7b72#Tff7b72define PROV_NS_RADIO 101
Tff7b72#Tff7b72define PROV_NS_NETWORK 102
Tff7b72#Tff7b72define PROV_NS_METRICS 103
Tff7b72#Tff7b72define PROV_NS_METRICS_IFACE 104
Tff7b72#Tff7b72define PROV_NS_IFACE_LORA 105
Tff7b72#Tff7b72define PROV_NS_IFACE_UDP 106
Tff7b72#Tff7b72define PROV_NS_METRICS_ADDRS 107
Tff7b72#Tff7b72define PROV_NS_METRICS_DEV 108
Tff7b72#Tff7b72define PROV_GENERAL_KISS_LOG 1
Tff7b72#Tff7b72define PROV_GENERAL_LORA_MODE 2
Tff7b72#Tff7b72define PROV_GENERAL_UDP_MODE 3
Tff7b72#Tff7b72define PROV_GENERAL_NOMADNET_ENABLE 4
Tff7b72#Tff7b72define PROV_GENERAL_NOMADNET_NAME 5
Tff7b72#Tff7b72define PROV_GENERAL_GPIO0 6
Tff7b72#Tff7b72define PROV_GENERAL_GPIO1 7
Tff7b72#Tff7b72define PROV_METRICS_TRANS_ID 1
Tff7b72#Tff7b72define PROV_METRICS_PROBE_DST 2
Tff7b72#Tff7b72define PROV_METRICS_MGMT_DST 3
Tff7b72#Tff7b72define PROV_METRICS_NOMAD_DST 4
Tff7b72#Tff7b72define PROV_METRICS_DEV_VER 1
Tff7b72#Tff7b72define PROV_METRICS_DEV_BATV 2
Tff7b72#Tff7b72define PROV_METRICS_DEV_BATP 3
Tff7b72#Tff7b72define PROV_METRICS_DEV_BATS 4
Tff7b72#Tff7b72define PROV_METRICS_LORA_FREQ 1
Tff7b72#Tff7b72define PROV_METRICS_LORA_BW 2
Tff7b72#Tff7b72define PROV_METRICS_LORA_SF 3
Tff7b72#Tff7b72define PROV_METRICS_LORA_CR 4
Tff7b72#Tff7b72define PROV_METRICS_LORA_TXP 5
Tff7b72#Tff7b72define PROV_METRICS_LORA_CRSSI 6
Tff7b72#Tff7b72define PROV_METRICS_LORA_NF 7
Tff7b72#Tff7b72define PROV_METRICS_LORA_LRSSI 8
Tff7b72#Tff7b72define PROV_METRICS_LORA_LSNR 9
Tff7b72#Tff7b72define PROV_METRICS_LORA_STAL 10
Tff7b72#Tff7b72define PROV_METRICS_LORA_LTAL 11
Tff7b72#Tff7b72define PROV_METRICS_UDP_ADDR 1
Tff7b72#Tff7b72define PROV_METRICS_UDP_PORT 2
Tff7b72#Tff7b72define PROV_METRICS_WIFI_SSID 3
Tff7b72#Tff7b72define PROV_RADIO_OP_MODE 1
Tff7b72#Tff7b72define PROV_RADIO_FREQ 2
Tff7b72#Tff7b72define PROV_RADIO_BW 3
Tff7b72#Tff7b72define PROV_RADIO_SF 4
Tff7b72#Tff7b72define PROV_RADIO_CR 5
Tff7b72#Tff7b72define PROV_RADIO_TXP 6
Tff7b72#Tff7b72define PROV_RADIO_IMPLICIT 7
Tff7b72#Tff7b72define PROV_RADIO_STAL 8
Tff7b72#Tff7b72define PROV_RADIO_LTAL 9
Tff7b72#Tff7b72define PROV_NET_IP 1
Tff7b72#Tff7b72define PROV_NET_PORT 2
Tff7b72#Tff7b72define PROV_NET_SSID 3
Tff7b72#Tff7b72define PROV_NET_MODE 4
T8b949e// Set true once Provisioning::Provisioner::begin() has run.
Tff7b72extern Tffa657bool Te6edf3provisioning_startedTb4b4b4;
T8b949e// Buffer for an in-flight CMD_PROVISION_REQ frame. Bytes are un-escaped
T8b949e// into here by the serial_callback() byte-accumulator branch and handed
T8b949e// to on_provision_request() at frame-end.
Tff7b72extern Te6edf3RNSTff7b72:Tff7b72:Te6edf3Bytes Te6edf3provision_rx_bufTb4b4b4;
T8b949e// Bring the Provisioning subsystem up. Must be called after the
T8b949e// filesystem has been registered with RNS::Utilities::OS so storage
T8b949e// reads can resolve.
Tffa657void Td2a8ffinit_provisioningTb4b4b4(Tb4b4b4)Tb4b4b4;
T8b949e// Dispatch one un-escaped MsgPack envelope to the Provisioning Provisioner
T8b949e// and emit the framed MsgPack response back over KISS.
Tffa657void Td2a8ffon_provision_requestTb4b4b4(Tff7b72const Te6edf3RNSTff7b72:Tff7b72:Te6edf3BytesTff7b72& Te6edf3reqTb4b4b4)Tb4b4b4;
T8b949e// Emit a CMD_PROVISION_RSP KISS frame carrying the given payload bytes.
Tffa657void Td2a8ffkiss_indicate_provision_responseTb4b4b4(Tff7b72const Te6edf3RNSTff7b72:Tff7b72:Te6edf3BytesTff7b72& Te6edf3payloadTb4b4b4)Tb4b4b4;
Tff7b72#Tff7b72endif T8b949e// HAS_PROVISIONING
Served by rngit 1.5.2 - Generated in 0.01s